'use strict';
var buildType = require('../consts/buildType');

var exp = module.exports;

var BUILD_ID_RIDE = 100;

/**
 * 根据建筑id获取建筑的类型
 * @param  {[type]} build_id [description]
 * @return {[type]}          [description]
 */
exp.getBuildType = function (build_id) {
    return parseInt(build_id / BUILD_ID_RIDE);
};

/**
 * 根据建筑类型和编号获取建筑的id
 * @param  {[type]} build_type [description]
 * @param  {[type]} build_num  [description]
 * @return {[type]}            [description]
 */
exp.getBuildId = function (build_type, build_num) {
    return parseInt(build_type * BUILD_ID_RIDE + build_num);
};

exp.isTower = function (build_type) {
    return build_type == buildType.ARROW_TOWER ||
        build_type == buildType.CANNON_TOWER ||
        build_type == buildType.ICE_TOWER ||
        build_type == buildType.LIGHT_TOWER ||
        build_type == buildType.CROSSBOW_TOWER ||
        build_type == buildType.DRAGON_TOWER ||
        build_type == buildType.SNOW_TOWER ||
        build_type == buildType.ELECTRIC_TOWER;
};
